package ThreadPool;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

public class TestThreadPool {
    public static void main(String[] args) {
//线程池(引用) -->Executors工厂类
        ExecutorService es = Executors.newFixedThreadPool(3);
     //1.创建任务对象
        MyTask task = new MyTask();
        //2.将任务提交给线程池,由线程调度,执行
        es.submit(task);
    }
}
class MyTask implements  Runnable{

    @Override
    public void run() {
        for (int i = 0; i < 50; i++) {
            System.out.println(Thread.currentThread().getName()+":"+i);
        }
    }
}